package com.wc.算法提高课.E第五章_数学知识.分解质因数.阶乘分解;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

/**
 * @Author congge
 * @Date 2024/10/3 16:29
 * @description https://www.acwing.com/problem/content/199/
 */
public class Main {
    /**
     * 思路：
     * 最暴力的做法
     */
    static FastReader sc = new FastReader();
    static PrintWriter out = new PrintWriter(System.out);
    static int N = 1000010, cnt = 0;
    static int[] primes = new int[N];
    static boolean[] st = new boolean[N];
    static int[] f = new int[N];
    static int n;

    static void ola(int n) {
        st[0] = st[1] = true;
        for (int i = 2; i <= n; i++) {
            if (!st[i]) primes[cnt++] = i;
            for (int j = 0; i * primes[j] <= n; j++) {
                st[i * primes[j]] = true;
                if (i % primes[j] == 0) break;
            }
        }
    }

    public static void main(String[] args) {
        n = sc.nextInt();
        ola(n);
        for (int i = 2; i <= n; i++) {
            int a = i;
            for (int j = 0; (long) primes[j] * primes[j] <= a; j++) {
                if (a % primes[j] == 0) {
                    int s = 0;
                    while (a % primes[j] == 0) {
                        a /= primes[j];
                        s++;
                    }
                    f[primes[j]] += s;
                }
            }
            if (a > 1) f[a] += 1;
        }
        for (int j = 0; j < cnt; j++) {
            if (f[primes[j]] > 0) out.printf("%d %d\n", primes[j], f[primes[j]]);
        }
        out.flush();
    }
}

class FastReader {
    StringTokenizer st;
    BufferedReader br;

    FastReader() {
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    String next() {
        while (st == null || !st.hasMoreElements()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }

    int nextInt() {
        return Integer.parseInt(next());
    }

    String nextLine() {
        String s = "";
        try {
            s = br.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return s;
    }

    long nextLong() {
        return Long.parseLong(next());
    }

    double nextDouble() {
        return Double.parseDouble(next());
    }

    // 是否由下一个
    boolean hasNext() {
        while (st == null || !st.hasMoreTokens()) {
            try {
                String line = br.readLine();
                if (line == null)
                    return false;
                st = new StringTokenizer(line);
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return true;
    }
}